<!--#include file="p1.asp" -->
<!DOCTYPE html>
<html>
<head>

  <title></title>
<%
easp.include "h.asp"
%>
</head>
<body>
<div style="padding: 20px; background-color: #F2F2F2;">
  <div class="layui-row">
    <div class="layui-col-md8">
      <div class="layui-card">
        <div class="layui-card-header">数据库创建</div>
        <div class="layui-card-body">
			<form class="layui-form" action="">
				<div class="layui-form-item">
					<label class="layui-form-label">创建新库：</label>
					<div class="layui-inline">
						<input type="text" name="dbName" lay-verify="dbName" placeholder="请输入新库名" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
					  <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">提交</button>
					</div>
				</div>
			</form>
        </div>
      </div>			
      <div class="layui-card">
        <div class="layui-card-header">数据库管理</div>
        <div class="layui-card-body">
		<label class="layui-form-label">库名</label>
		<div class="layui-inline">
			<input type="text" id='dbName1' name="dbName1" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-inline">
			<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="user-front-search">
			<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
		</button>
          </div>
		  <br><br>
		<table id="user" lay-filter="user"></table>
		<script type="text/html" id="barDemo">
		  <a class="layui-btn layui-btn-xs" lay-event="dbinfo">项目信息管理</a>
		  <a class="layui-btn layui-btn-xs" lay-event="exp3">导出</a>
		  <a class="layui-btn layui-btn-xs" lay-event="manage">管理</a>
		  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
		</script>			
        </div>
      </div>			
    </div>  
    <div class="layui-col-md5">

    </div>
  </div>
</div> 
<script src="dist/layuiadmin/layui/layui.js"></script>
<script>
  layui.config({
    base: 'dist/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'contlist', 'table','useradmin', 'form'], function(){
    var $ = layui.$
    ,admin = layui.admin
	,table=layui.table
    ,form = layui.form;
	table.render({
        elem: '#user',
        url: 'yw1.asp?action=xx',
        cols: [[
{type:'checkbox'},		
        {
            field: 'id',
            title: 'id',
            width: 60,
            sort: true,
            fixed: false
        },
        {
            field: 'dbName',
            title: '库名',
            width: 300
        },
        {
            field: 'dbinfo',
            title: '简介',
            width: 100
        },		
        {
            field: 'rq',
            title: '创建时间',
            width: 110
        },
        {
            fixed: 'right',
            width: 320,
            align: 'center',
            toolbar: '#barDemo'
        }		
]],
        id: 'user',
        limit: 10,
        page: true,
        height: 475
    });	
    form.on('submit(user-front-search)', function(data){
      var dbName1 = $('#dbName1').val();
      table.reload('user', {
        where: 
		{  
			dbName1: dbName1
        }    
      });
      layer.msg('已重载');	  
    });	
  form.on('submit(demo1)', function(data){
		var field = data.field;
		$.post('yw1.asp?now=' + new Date().getTime(), {
			data:field,
			action: "newDb"
		},
		function(data) {
			if (data == '1') {
				layer.msg("成功!!");
				table.reload('user');				
			} else {
				layer.msg("失败！！ "+data);
			}
		});    
    return false;
  });
  
  form.verify({
  dbName: function(value, item){ //value：表单的值、item：表单的DOM对象
	if(value==""){
		return '数据库名不能为空！！';
	}
	if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
      return '数据库名不能有特殊字符';
    }
	if(value.length<3){
		return '数据库名必须大于2个字符';
	}
    if(/(^\_)|(\__)|(\_+$)/.test(value)){
      return '数据库名首尾不能出现下划线\'_\'';
    }
    if(/^\d+\d+\d$/.test(value)){
      return '数据库名不能全为数字';
    }
  }
  ,pass: [
    /^[\S]{6,12}$/
    ,'密码必须6到12位，且不能出现空格'
  ] 
}); 

    table.on('tool(user)',
    function(obj) {
        var data = obj.data;
        if (obj.event === 'dbinfo') {
	layer.prompt({title: '请输入项目简介：', formType: 2,value:data.dbinfo }, function(text, index){
		$.post('p2.asp?now=' + new Date().getTime(), {
			id:data.id,
			dbinfo: text,
			action: "dbinfo"
		},
		function(data) {
			if (data == '1') {
				layer.confirm('成功！', {skin: 'layui-layer-molv' ,title:'提示'}, function(index){
				window.location.href=document.URL;  

			});
			} else {
				layer.alert("失败！！ "+data, {
				  skin: 'layui-layer-molv' //样式类名
				  ,shadeClose: true, closeBtn: 0
				});				
			}
		});
		layer.close(index);
      });			
			
			//location.href='p2.asp?action=dbinfo'+'&id='+data.id;
        }
	
		else if (obj.event === 'exp3') {
			$.post('p2.asp?now=' + new Date().getTime(), {
				id: data.id,
				dbName: data.dbName,
				action: "exp3"
			},
			function(data) {
				if (data == '1') {
					layer.msg("成功!!");
				} else {
					layer.msg("失败！！ "+data);
				}
			});			
		}
		else if (obj.event === 'manage') {
			location.href='ct11.asp?key=db'+'&str=manage&dbName='+data.dbName;
		}		
		else if (obj.event === 'del') {
			var _this = $(this);
			layer.confirm('您确定删除此信息？' + data.id, {
				icon: 3,
				title: '提示信息'
			},
			function(index){
				$.post('yw1.asp?now=' + new Date().getTime(), {
					id: data.id,
					dbName: data.dbName,
					action: "dbsdel"
				},
				function(data) {
					if (data == '1') {
						layer.msg("成功!!");
					} else {
						layer.msg("失败！！ "+data);
					}
				});
				layer.close(index);
				table.reload('user');				
			});
		}	
	});	
});	
</script>
</body>
</html>